package com.xpsoft.oa.dao.project.impl;


import java.math.BigDecimal;

import org.hibernate.Query;

import com.xpsoft.core.dao.impl.BaseDaoImpl;
import com.xpsoft.oa.dao.project.ProjectPaymentDao;
import com.xpsoft.oa.model.project.ProjectPayment;

public class ProjectPaymentDaoImpl extends BaseDaoImpl<ProjectPayment> implements ProjectPaymentDao{

	public ProjectPaymentDaoImpl() {
		super(ProjectPayment.class);
	}

	@Override
	public BigDecimal getPayedByProId(Long proId,Long suppliersId) {
		// TODO Auto-generated method stub
		String hql = "select sum(applyAmount) from ProjectPayment where project.id=:proId and suppliersAssess.suppliersId=:suppliersId";
		Query query = getSession().createQuery(hql);
		Object obj = query.setParameter("proId", proId).setParameter("suppliersId", suppliersId).uniqueResult();
		BigDecimal payed = new BigDecimal(0);
		if(obj!=null){
			payed = (BigDecimal)obj;
		}
		return payed;
	}

	
}